package leo;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.impl.StdSchedulerFactory;

/**
 * Servlet implementation class JobList
 */
public class JobList extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public JobList() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("### JobList-doGet... ");
		SchedulerFactory sf = new StdSchedulerFactory();
		Scheduler sched;
		try {
		 	PrintWriter out = response.getWriter();
		 	out.println("<h1>Job List </h1>");
			sched = sf.getScheduler();
			for (String obj : sf.getScheduler().getJobNames(sched.DEFAULT_GROUP)) {
				out.println("-->" + obj + " </br>");
			}

			
		}catch (SchedulerException e) {
			e.printStackTrace();
		}	
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("### JobList-doPost... " );

	}

}
